package com.zb.zbtcommon.service.impl;

import com.zb.zbtcommon.dao.NewsDao;
import com.zb.zbtcommon.entity.News;
import com.zb.zbtcommon.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsDao newsDao;
    @Override
    public List<News> findNews(String newstypeid,int currentPage) {
        Map<String ,Object> param= new HashMap<String ,Object>();
        param.put("start", (currentPage-1)*5);
        param.put("pageSize", 5);
        param.put("newstypeid", newstypeid);
        List<News> list = newsDao.findNews(param);
        return  list;
    }

    @Override
    public int findNewsCount(String newtypeid) {
        return newsDao.findNewsCount(newtypeid);
    }

    @Override
    public List<News> findNewsInnovate() {
        return newsDao.findNewsInnovate();
    }

    @Override
    public List<News> findNewsIntellectual() {

        return newsDao.findNewsIntellectual();}

    @Override
    public List<News> findNewsQualification() {
        return newsDao.findNewsQualification();}

    @Override
    public List<News> findNewsTechnolog() {
        return newsDao.findNewsTechnolog(); }

    @Override
    public News findNewsById(String newsid)
    {
        return newsDao.findNewsById(newsid);
    }

    @Override
    public List<News> pageList(String newstypeid) {
        return newsDao.pageList(newstypeid);
    }
    public int saveNews(News news) {
        return newsDao.saveNews(news);
    }
    @Override
    public int updateNews(News news) {
        return newsDao.updateNews(news);
    }
    @Override
    public List<News> findNewsList(String title, String newstypeid, int currentPage) {
        Map<String ,Object> result=new HashMap<String, Object>();
        result.put("start", (currentPage-1)*10);
        result.put("pageSize", 10);
        result.put("title", title);
        result.put("newstypeid", newstypeid);
        result.put("currentPage", currentPage);
        List<News> list =newsDao.findNewsList(result);
        return list;
    }
    @Override
    public int deleNews(String newsid) {
        return newsDao.deleNews(newsid);
    }
}
